﻿<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>创建图标</title>
    <style type="text/css">
        #maps
        {
            height: 450px;
        }
    </style>
<!--    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=zh-CN"></script>-->
    <script type="text/javascript" src="http://ditu.google.cn/maps/api/js?sensor=false&language=zh-CN"></script>
    <script type="text/javascript" language="javascript">
        //地图初始化函数
            function initialize() {
            var Options = {
                zoom: 10, center: new google.maps.LatLng(-33.9, 151.2), mapTypeId: google.maps.MapTypeId.ROADMAP
            }
            var map = new google.maps.Map(document.getElementById("maps"), Options);
            setMarkers(map, beaches);
        }
        //图标数据对象数组
        var beaches = [
        ['Bondi Beach', -33.890542, 151.273856, 4],
        ['Coogee Beach', -33.923036, 151.25902, 5],
        ['Cronulla Beach', -34.028249, 151.157507, 3],
        ['Manly Beach', -33.80010128657071, 151.2874782854187, 2],
        ['Maroubra Beach', -33.950198, 151.259302, 1]
        ];
        //创建并设置图标
        function setMarkers(map, locations) {
            //创建图标
            var image = new google.maps.MarkerImage(
             "./images/marke/car1.gif",
             new google.maps.Size(20, 32),
             new google.maps.Point(0, 0),
               new google.maps.Point(0, 32)
             );
            //创建阴影图标
            var shadow = new google.maps.MarkerImage(
            "./images/marke/car2.gif",
            new google.maps.Size(300, 320),
            new google.maps.Point(0, 0),
            new google.maps.Point(0, 32)
            );
            //外形
            var shape = { coord: [1, 1, 1, 20, 18, 20, 18, 1],
                type: "poly"
            };
            //遍历图标数据数组，创建图标
            for (var i = 0; i < locations.length; i++) {
                var beach = locations[i];
                var LatLng = new google.maps.LatLng(beach[1], beach[2]);
                var marker = new google.maps.Marker(
                {
                    position: LatLng, map: map, shadow: shadow, icon: image, shape: shape, title: beach[0], zIndex: beach[3]
                }
                );
            }
        }
                   
    </script>

</head>
<body onload='initialize()'>
    <div id="maps">
    </div>
</body>
</html>

